/**
 * 	This file is part of GMGraphLib.
 * 
 * 	GMGraphLib is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  GMGraphLib is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *  
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with GMGraphLib.  If not, see <http://www.gnu.org/licenses/>.
*/
package br.mendonca.gmgraphlib;

import java.util.LinkedList;
import java.util.List;


/**
 * @author Gabriel Mendonça - gabrielgmendonca@gmail.com
 *
 */
public class AdjacencyListEdges extends EdgeList {

	private static final long serialVersionUID = 2962480744980492420L;

	public AdjacencyListEdges(int numberOfVertices) {
		super(numberOfVertices);
	}

	/* (non-Javadoc)
	 * @see br.mendonca.gmgraphlib.EdgeList#addNewVertex()
	 */
	@Override
	public void addNewVertex(int numberOfVertices) {
		add(new LinkedList<Integer>());
	}

	@Override
	public void addEdge(int v1, int v2) {		
		get(v1 - 1).add(v2);					
	}

	@Override
	public List<Integer> getNeighborsIndex(int vertexIndex) {		
		return get(vertexIndex - 1);
	}

	public boolean hasNext() {		
		return (v1Index < size() && v2Index < get(v1Index).size());
	}
		
}
